package org.hyf.inspur.LessonDesin.clear.count2;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.hyf.inspur.LessonDesin.clear.count.PvMain;
import org.hyf.inspur.LessonDesin.clear.count.PvMapper;
import org.hyf.inspur.LessonDesin.clear.count.PvReducer;

public class UvMain {
    public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        //设置map内存使用
        Job job = Job.getInstance(conf,"wc");
        job.setJarByClass(UvMain.class);
        //map类
        job.setMapperClass(UvMapper.class);
        //map输出k-v数据类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);
        //不使用reduce
        job.setReducerClass(UvReducer.class);
        //job.setNumReduceTasks(0);
        //结果数据输出类型
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);
        job.setInputFormatClass(TextInputFormat.class);
        //将输入文件切片最小64M，最大128M
        //TextInputFormat.setMinInputSplitSize(job, 1024 * 1024 * 64L); // 设置最小分片大小
        //TextInputFormat.setMaxInputSplitSize(job, 1024 * 1024 * 64L); // 设置最大分片大小
        //输入路径
        FileInputFormat.addInputPath(job, new Path("d://data/output/output2/part-r-00*"));

        FileOutputFormat.setOutputPath(job, new Path("d://data/output/output3"));
        //提交作业 判断退出条件（0正常退出，1非正常退出）
        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
}
